Technical Q&A QA1141
Disabling a Processor on a Multiprocessor System


Q: I have a Macintosh computer with multiple processors. I'd like to temporarily turn off one of the processors to test my Mac OS X product in a single-processor environment. How can I do that?

A: For all Power Macintosh systems with Open Firmware, you can change a setting to make the system believe that there are fewer processors than are actually present. You can use the Terminal application in Mac OS X to enter the nvram command and reboot the system. Or, there is a method which works within the Open Firmware environment.



Using the Mac OS X Terminal to Set the Number of Processors to One

The following instructions work for Mac OS X only. You must have the root or admin password in order to make this change. You will use the Terminal application to issue the nvram command to set the "boot-args" configuration variable. Follow these steps:

Step 1. Launch the Terminal application. The Terminal application is found at /Applications/Utilities/Terminal.

Step 2. To see the current setting of "boot-args", enter the following command:


         % nvram boot-args


Step 3. Enter the following command


         % sudo nvram boot-args="cpus=1"

You will need to reenter the current value of "boot-args" if you want to preserve it. For example, if the result of Step 2 was:


         boot-args       debug=0x4

the nvram command would read:


         % sudo nvram boot-args="debug=0x4 cpus=1"


Step 4. Enter the root or administrator password when prompted.

Step 5. Restart the system.

The above command sets the "boot-args" Open Firmware configuration variable in nonvolatile RAM (NVRAM). This means that the setting is persistent across system restarts. If you decide to change the setting before restarting, a subsequent setting will overwrite a preceding setting. If you misspell "boot-args", there is no warning, a (probably useless) new entry into NVRAM is made, and the number of processors used will be unchanged after restart.

An important caveat - the number of processors must be at least 1 and can't be greater than the number of processors physically present in the system. If you specify an invalid number of processors, your system may hang during the boot process. If this happens, you will need to "zap PRAM" as described in the next section "Clearing the "cpus" Setting."

Note that you can also set the boot-args configuration variable within Open Firmware. This option is discussed at the end of this Q&A under the section "Setting the Number of Processors for Mac OS X using "cpus" in Open Firmware."



Clearing the "cpus" Setting

The cpus setting is set in NVRAM and will affect all system restarts until the setting is changed or cleared. Use the instructions above to set "cpus" to a different value. To clear the cpus setting, there are three options.

1. Use the Terminal application to clear the boot-args configuration variable. For example, you could enter the following command within the Terminal application:


         % sudo nvram boot-args=""

This command sequence clears the value of boot-args.

2. You can clear boot-args by "zapping PRAM." Restart the system and hold down the "Command-Option-P-R" keys until you hear the boot beep a second time. Release the keys and the system will restart normally with all CPUs recognized. Keep in mind that this also will clear all other custom NVRAM settings.

3. Finally, you can clear the "cpus" setting by running System Preferences and clicking Startup Disk. Then switch the startup disk to a different volume. This clears all contents of the boot-args configuration variable and is similar to using the Terminal application to clear this setting.



Setting the Number of Processors for Mac OS X using "cpus" in Open Firmware

You can create the same cpus setting in NVRAM using the Open Firmware user interface. Once the setting is in NVRAM, the setting persists across system restarts.

To set the value of cpus from within Open Firmware, follow these instructions:

Step 1. Enter Open Firmware.
Restart the system and hold the "Command-Option-O-F" keys down until the Open Firmware screen is displayed.

Step 2. To see the current setting of "boot-args", enter the following:


         cr boot-args type cr

(Open Firmware aficionados may notice that printenv boot-args will accomplish the same thing. However, that will print the hexadecimal value of each character in "boot-args" and not a human-readable text string.)

Step 3. Enter the following command:


         setenv boot-args cpus=1

Note that there are no double quote characters used in this command line as there are when using the Terminal application.

You will need to reenter the current value of "boot-args" if you want to preserve it. For example, if the result of Step 2 was:


         debug=0x4
          ok

the command would read:


         setenv boot-args debug=0x4 cpus=1


Step 3. After the "ok" response, enter


         mac-boot

to continue the boot process.

To clear this setting, refer to the options described above in the section "Clearing the "cpus" Setting."



References

Tech Note 1061 Fundamentals of Open Firmware, Part I: The User Interface, Part I in the Open Firmware Technote Series

Tech Note 2004 Debugging Open Firmware Using Telnet

Tech Note 1062 Fundamentals of Open Firmware, Part II: The Device Tree Part II in the Open Firmware Technote Series

[May 22 2002]


Developer Documentation | Technical Notes | Development Kits | Sample Code